<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    canvas {
      border: 1px solid #333;
    }
  </style>
</head>

<body>
  <canvas width="600" height="400"></canvas>
  <script>
    let canvas = document.querySelector("canvas")
    let ctx = canvas.getContext("2d")

    ctx.fillStyle = "red"
    let y = 0;

    setInterval(() => {
      ctx.clearRect(275,y,50,50)
      y++
      ctx.fillRect(275, y, 50, 50)
    }, 100);


  </script>

</body>

</html>